﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
	Layout = null;
}

<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>@*
<script src="~/lib/layuiadmin/layui/layui.js"></script>
<script src="~/lib/layuiadmin/config.js"></script>
<link href="~/lib/layuiadmin/layui/css/layui.css" rel="stylesheet" /> *@



<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Demo</title>
	<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
	@* <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet"> *@
</head>
<body>

	<form class="layui-form">



		<div class="layui-form-item">
			<label class="layui-form-label">资源编码</label>
			<div class="layui-input-block">
				<input type="text" name="resourceNo" lay-verify="required" id="resourceNo" autocomplete="off" class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-form-item">
				<label class="layui-form-label">资源名称</label>
				<div class="layui-input-block">
					<input type="text" name="resourceName" lay-verify="required" id="resourceName" autocomplete="off" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">资源类别</label>
				<div class="layui-input-block">
					<select name="resourceType" id="resourceType" lay-filter="aihao">
						<option value="">请选择</option>
						<option value="设备">设备</option>
						<option value="金额">金额</option>
						<option value="杂项">杂项</option>
						<option value="人员">人员</option>
					</select>
				</div>
			</div>






			<div class="layui-form-item">
				<label class="layui-form-label">资源单位</label>
				<div class="layui-input-block">
					<select name="resourceDw" id="resourceDw" lay-filter="aihao">
						<option value="">请选择</option>
						<option value="次">次</option>
						<option value="克">克</option>
						<option value="毫克">毫克</option>
						<option value="千克">千克</option>
						<option value="小时">小时</option>
						<option value="人">人</option>
					</select>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">计算成本</label>
				<div class="layui-input-block">
					<select name="resourceMoney" id="resourceMoney" lay-filter="aihao">
						<option value="">请选择</option>
						<option value="是">是</option>
						<option value="否">否</option>

					</select>
				</div>
			</div>


			<div class="layui-form-item">
				<label class="layui-form-label">计费方式</label>
				<div class="layui-input-block">
					<select name="moneyType" id="moneyType" lay-filter="aihao">
						<option value="">请选择</option>
						<option value="手工">手工</option>
						<option value="采购自动系统">采购自动系统</option>
						<option value="车间自动系统">车间自动系统</option>

					</select>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">费用类型</label>
				<div class="layui-input-block">
					<select name="resourceCost" id="resourceCost" lay-filter="aihao">
						<option value="">请选择</option>
						<option value="管理人员工资">管理人员工资</option>
						<option value="职工福利">职工福利</option>
						<option value="水电费">水电费</option>
						<option value="保险费">保险费</option>
						<option value="固定资产折旧费">固定资产折旧费</option>
						<option value="差旅费">差旅费</option>
						<option value="修理费">修理费</option>
						<option value="机物料消耗">机物料消耗</option>
					</select>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-block">
					<select name="resourceSmark" id="resourceSmark" lay-filter="aihao">
						<option value="">请选择</option>
						<option value="有效">有效</option>
						<option value="无效">无效</option>
						
					</select>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit lay-filter="demo1">保存</button>
				</div>
			</div>

		</div>
	</form>
	
</body>
</html>


<script>
	layui.use(function () {
		var form = layui.form;
		var layer = layui.layer;

		// 提交事件
		form.on('submit(demo1)', function (d) {
			var data = {

				resourceNo: $("#resourceNo").val(),
				resourceName: $("#resourceName").val(),
				resourceType: $("#resourceType").val(),
				resourceDw: $("#resourceDw").val(),
				resourceMoney: $("#resourceMoney").val(),
				moneyType: $("#moneyType").val(),
				resourceCost: $("#resourceCost").val(),
				resourceSmark: $("#resourceSmark").val(),

			};
			$.ajax({
				url:'@ViewBag.RBACWrite' + "/api/Resource/addUsers",
				type: 'post',
				data: JSON.stringify(data),
				dataType: "json",
				contentType: "application/json",

				success: res => {
					if (res.code == 0) {
						layer.msg('添加成功')
						 location.href = "/Sources/SourcesShow/"
					}
					else {
						layer.msg('保存失败')
					}
				}
			})
			return false; // 阻止默认 form 跳转
		});

	});




</script>

